package com.example.weixinauth.feign;

import com.weixin.common.core.constant.SecurityConstants;
import com.weixin.common.core.domain.LoginUser;
import com.weixin.common.core.domain.Result;
import com.weixin.common.core.entity.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0.0
 * @className: FeignUserService
 * @description:
 * @author: zhangjunfa
 * @date: 2023/6/8 15:18
 */
// @FeignClient(value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
@FeignClient(name = "weixin-system", path = "/user")
public interface FeignUserService {

    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/info/{username}")
    public Result<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping("/register")
    public Result<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
